<%--
  Created by IntelliJ IDEA.
  User: MAVI003
  Date: 2017/3/20
  Time: 9:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
    <title>用户登录</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/images/icon.jpg">
    <link rel="bookmark" href="${pageContext.request.contextPath}/images/icon.jpg">

    <link href="//cdn.bootcss.com/bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
    <link href="http://ibootstrap-file.b0.upaiyun.com/www.layoutit.com/css/builder/v3/layoutit.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/layoutit.css" rel="stylesheet">
    <script type="text/javascript" src="http://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://cdn.staticfile.org/jqueryui/1.10.2/jquery-ui.min.js"></script>
    <script type="text/javascript"
            src="http://cdn.staticfile.org/jqueryui-touch-punch/0.2.2/jquery.ui.touch-punch.min.js"></script>
    <script type="text/javascript" src="http://cdn.staticfile.org/twitter-bootstrap/3.0.1/js/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="http://ibootstrap-file.b0.upaiyun.com/www.layoutit.com/js/jquery.htmlClean.js"></script>
    <script type="text/javascript"
            src="http://ibootstrap-file.b0.upaiyun.com/www.layoutit.com/js/builder/v3/scripts.min.js"></script>
    <style type="text/css">
        body{
            background-image: url(${pageContext.request.contextPath}/images/7.jpg);
            background-size:cover;
        }
        .myback{
            background-image: url(${pageContext.request.contextPath}/images/9.jpg);
            background-size:cover;
        }
    </style>
    <script>
        $(document).ready(function () {
            $("#login").click(function () {
                var uname = $("#uname").val();
                var upassword = $("#upassword").val();
                var flag = -1;
                $.ajax({
                    type: 'get',
                    url: '${pageContext.request.contextPath}/checkLogin',
                    async: false,
                    data: {
                        uname: uname,
                        upassword: upassword
                    },
                    dataType: 'text',
                    success: function (data) {

                        flag = data;

                    },
                    error: function () {
                        flag = -1;

                    }
                });

                if (flag == 0 || flag == 2) {
                    //0:用户名不存在
                    //2:密码错误
                    alert("用户名或密码不正确");
                    return false;
                } else if (flag == 1) {

                    alert("登录成功");
                    location.href = "${pageContext.request.contextPath}/showIndex";
                    return true;
                } else if (flag == 3) {

                    alert("登录成功：管理员");
                    location.href = "${pageContext.request.contextPath}/showAdminBeforeCheck";
                    return true;
                }
            })
        })
    </script>

</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-2 column hideLine myback">
        </div>
        <div class="col-md-6 column hideLine myback">
            <div class="page-header">
                <h1>
                    拍卖系统用户登录
                </h1>
            </div>
        </div>

    </div>
    <div class="row clearfix hideLine">
        <div class="col-md-12 column hideLine myback">
            <form class="form-horizontal" role="form">
                <div class="form-group">
                    <label for="uname" class="col-sm-2 control-label">用户名</label>
                    <div class="col-sm-5">
                        <input type="tel" class="form-control" id="uname"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="upassword" class="col-sm-2 control-label">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</label>
                    <div class="col-sm-5">
                        <input type="password" class="form-control" id="upassword"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <div class="checkbox">
                            <h4>没有账号？去<a href="${pageContext.request.contextPath}/showReg">注册</a>！</h4>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-default" id="login">登录</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
